package com.tedu.bill.demo7;

import java.util.Arrays;
import java.util.Comparator;

/**
 * Author：毕龙
 * Date: 2024/5/7 19:39
 */
public class TestLambda1 {
    public static void main(String[] args) {
       int[] arrs = {1,3,8,5,7,2};
       Arrays.sort(arrs);
       System.out.println(Arrays.toString(arrs));
        Student[] students = {
                new Student(1),
                new Student(8),
                new Student(3),
                new Student(9),
                new Student(5)
        };
        Arrays.sort(students, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o2.getAge()-o1.getAge();
            }
        });
        System.out.println(Arrays.toString(students));

        Arrays.sort(students,(s1,s2)->{return s1.getAge()-s2.getAge();});

        System.out.println(Arrays.toString(students));

        Arrays.sort(students,(s1,s2)->s2.getAge()-s1.getAge());

        System.out.println(Arrays.toString(students));


    }
}
